<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div {
      margin-top: 100px;
      width: 200px;
      height: 200px;
      background-color: pink;
    }
  </style>
</head>
<input type="text">
<div></div>

<body>
  <!-- <script>
    function deal(a, b) {
      console.log('向后端发情求！');
      console.log(a + b);
    }
    // 👇防抖
    function debounce(fn, wait) {
      let timeId
      return (...args) => {
        clearTimeout(timeId)
        timeId = setTimeout(() => {
          fn.call(this, ...args)
        }, wait);
      }

    }
    // 👇节流1
    function throttle1(fn, wait) {
      let timeId = null
      return (...args) => {
        if (!timeId) {
          timeId = setTimeout(() => {
            fn.call(this, ...args)
            timeId = null
          }, wait)
        }
      }

    }
    // 👇节流2
    function throttle2(fn, wait) {
      let pre = 0
      return (...args) => {
        let now = +new Date()
        if (now - pre >= wait) {
          fn.call(this, ...args)
          pre = +new Date()
        }
      }
    }
    const ipt = document.querySelector('input')
    ipt.oninput = debounce(deal, 2000).bind(ipt, 3, 7)

    const div = document.querySelector('div')
    div.onclick = throttle2(deal, 3000).bind(div, 6, 6)
  </script> -->


  <!-- <script>
    function b() {
      afanfan = 10
      console.log(afanfan);
    }
    console.log(window);
    b()
    console.log(window.afanfan);
  </script> -->
</body>

</html>